<?php
$this->render('include/sortLink.phtml');
echo $this->render('resource/advertise/_tab.phtml');
$this->headScript()->appendFile(_STATIC_HTTP . '/jquery/checkAll.js');
if(!function_exists('__sortLink')) {
	function __sortLink() {}
}
?>
<form action="" method="post">
<div class="body">
	<table class="list">
		<tr>
			<th class="narrow sort"><?php echo __sortLink('id', '#', array('id' => $this->row->getId()));?></th>
			<th><?php echo $this->language('NAME');?></th>
			<th class="id"><?php echo $this->language('WIDTH');?></th>
			<th class="id"><?php echo $this->language('HEIGHT');?></th>
			<th><?php echo $this->language('DEVICE');?></th>
			<th><?php echo $this->language('DISPLAY');?></th>
			<th class="narrow sort"><?php echo __sortLink('display_order', 'D', array('id' => $this->row->getId()));?></th>
			<th class="narrow center"><?php echo '<input type="checkbox" name="select-all" id="select-all" value="1" rel="id[]" />';?></th>
		</tr>
		<?php
		$setting = new system_setting_language();
		foreach($this->list AS $row) {
			$langs = array();
			if(isset($this->langs[$row->getId()])) {
				foreach($this->langs[$row->getId()] AS $key => $lang) {
					$langs[] = '<li style="clear:both;">' . 
								'<span style="float:left;font-family:Arial;color:red;">' . date('Y-m-d H:i:s', $lang['start_time']) . 
								'</span><span style="float:left;font-weight:bold;padding:0 10px;"> TO </span>' .
								'<span style="float:left;font-family:Arial;color:red;">' . date('Y-m-d H:i:s', $lang['end_time']) . '</span>' .
								'<strong style="float:left;margin-left:10px;">' . 
								$setting->getName($key) . ' - ' . $setting->getTitle($key) . ' / ' . $setting->getTimezone($key) . 
								'</strong></li>';
				}
			}
			$devices = isset($this->devices[$row->getId()]) ? $this->devices[$row->getId()] : array();
		?>
		<tr>
			<td class="center"><?php echo $row->getId();?></td>
			<td><?php echo $row->getName();?></td>
			<td><?php echo $row->getWidth();?> px</td>
			<td><?php echo $row->getHeight();?> px</td>
			<td><?php echo implode('; ', $devices);?></td>
			<td rowspan="2"><ul style="padding:0;"><?php echo implode('', $langs);?></ul></td>
			<td rowspan="2" class="center"><h1><?php echo $row->getDisplayOrder();?></h1></td>
			<td class="center" rowspan="2"><?php
				if(in_array($row->getId(), $this->checkedList)) {
					$checked = array('checked' => 'checked');
				} else {
					$checked = array();
				}
				echo $this->form()->checkbox('id[]', $row->getId(), array_merge(array('id' => 'id-' . $row->getId()), $checked));
			?></td>
		</tr>
		<tr>
			<td><a href="<?php echo $this->url('resource/advertise/item', array('id' => $this->row->getId(), 'o' => 'edit', 'item_id' => $row->getId()));?>"><?php echo $this->language('Edit');?>»</a></td>
			<td colspan="4"><a href="<?php echo $this->url('resource/advertise/item', array('id' => $this->row->getId(), 'o' => 'edit', 'item_id' => $row->getId()));?>"><?php echo $this->escape($row->getDescription());?></a></td>
		</tr>
		<?php } ?>
		<?php if(count($this->list) <= 0) {?>
		<tr>
			<td colspan="8" class="nohover">
				<div class="msg">
					<div class="common error" style="border:0;background:#fff;">
						<i class="icon"></i>
						<h4>STOP</h4>
						<div class="msg-bd">
							No Item found. 
							<a href="<?php echo $this->url('resource/advertise/item', array('id' => $this->row->getId(), 'o' => 'addnew'));?>"><?php echo $this->language('Create');?></a>
						</div>
					</div>
				</div>
			</td>
		</tr>
		<?php } ?>
	</table>
</div>
<div class="body">
	<div style="float:right;margin-bottom:5px;">
		<?php echo $this->render('include/deleteButton.phtml');?>
	</div>
	<?php echo $this->paginator($this->list)->render();?>
</div>
</form>
